home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / utils / adt / name.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.1 KB  |  62 lines

  1. /*
  2.  * name.c --
  3.  *    Functions for the internal type "name".
  4.  */
  5.  
  6. #include <string.h>
  7.  
  8. #include "tmp/postgres.h"
  9.  
  10. RcsId("$Header: /private/postgres/src/utils/adt/RCS/name.c,v 1.6 1991/11/09 01:52:07 mer Exp $");
  11.  
  12.         /* ========== USER I/O ROUTINES ========== */
  13.  
  14.                  /* (none) */
  15.  
  16.  
  17.          /* ========== PUBLIC ROUTINES ========== */
  18.  
  19.      /* (see char.c for comparison/operation routines) */
  20.  
  21.  
  22.  
  23.          /* ========== PRIVATE ROUTINES ========== */
  24.  
  25. /* name.c */
  26. bool NameIsEqual ARGS((Name name1 , Name name2 ));
  27. uint32 NameComputeLength ARGS((Name name ));
  28.  
  29. /*
  30.  * Note:
  31.  *    This is the same code as char16eq.
  32.  *    Assumes that "xy\0\0a" should be equal to "xy\0b".
  33.  *    If not, can do the comparison backwards for efficiency???
  34.  */
  35. bool
  36. NameIsEqual(name1, name2)
  37.     Name    name1;
  38.     Name    name2;
  39. {
  40.     if (! PointerIsValid(name1) || ! PointerIsValid(name2)) {
  41.         return(false);
  42.     }
  43.     return((bool)(strncmp(name1, name2, 16) == 0));
  44. }
  45.  
  46. uint32
  47. NameComputeLength(name)
  48.     Name    name;
  49. {
  50.     char    *charP;
  51.     int    length;
  52.  
  53.     Assert(NameIsValid(name));
  54.  
  55.     for (length = 0, charP = (char *)name; length < 16 && *charP != '\0';
  56.             length++, charP++) {
  57.         ;
  58.     }
  59.     return (uint32)length;
  60. }
  61.  
  62.